<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('parent_id')->nullable()->comment('直属上级ID');
            $table->unsignedInteger('department_id')->comment('部门ID');
            $table->unsignedInteger('scope_id')->comment('数据域ID');
            $table->string('username', 50)->comment('姓名');
            $table->string('nickname')->nullable()->comment('昵称');
            $table->string('phone', 20)->unique()->comment('电话号码');
            $table->string('email')->unique()->comment('邮箱');
            $table->string('password')->comment('登陆密码');
            $table->string('job')->nullable()->comment('职位');
            $table->unsignedTinyInteger('gender')->default(0)->comment('性别，0:女,1:男');
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('data_scope')->comment('数据域');
            $table->string('identity_card')->nullable()->comment('身份证号');
            $table->string('telphone')->nullable()->comment('电话');
            $table->string('province')->nullable()->comment('省');
            $table->string('city')->nullable()->comment('市');
            $table->string('area')->nullable()->comment('区');
            $table->string('address')->nullable()->comment('详细地址');
            $table->string('region')->nullable()->comment('所属大区');
            $table->string('region_province')->nullable()->comment('所属大区省份');
            $table->unsignedTinyInteger('is_blocked')->default(0)->comment('是否禁用，0:未禁用,1:禁用');
            $table->text('session')->nullable()->comment('session信息');
            $table->timestamp('activated_at')->nullable()->comment('账号激活时间');
            $table->timestamp('lastvisited_at')->nullable()->comment('最后登陆时间');
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();

            $table->comment = '登陆用户表';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }

}
